﻿using MediatR;
using Microsoft.AspNetCore.Http.HttpResults;
using RBAC.Domain;
using RBAC.Domain.Service.Interfae;
using RBACDuYaJun.Api.Appliction.Command.MenuCommand;

namespace RBACDuYaJun.Api.Appliction.CommandHandlers.MenuHanders
{
    public class MenuCreateCommandHandler : IRequestHandler<MenuCreateCommand, int>
    {
        private readonly IMenuService _menuService;
        public MenuCreateCommandHandler(IMenuService menuService)
        {
            _menuService = menuService;
        }
        public async Task<int> Handle(MenuCreateCommand request, CancellationToken cancellationToken)
        {
            return await _menuService.AddMenu(new Menu()
            {
                MenuName= request.MenuName,
                MenuUrl= request.MenuUrl,
                MenuPid= request.MenuPid,
                MenuDelete = false,
                CreateBy="张三",
                CreateDate=DateTime.Now
            });
        }
    }
}
